package com.jstyle.jclifexd.daoManager;

import com.jstyle.jclifexd.dao.BindDeviceInfoDao;
import com.jstyle.jclifexd.model.BindDeviceInfo;
import com.jstyle.jclifexd.utils.DbManager;

import org.greenrobot.greendao.query.QueryBuilder;

import java.util.List;

/**
 * Created by Administrator on 2018/7/9.
 */

public class BindDeviceInfoDaoManager {
    public static void insertData(BindDeviceInfo bindDeviceInfo){
        DbManager.getInstance().getDaoSession().getBindDeviceInfoDao().insertOrReplace(bindDeviceInfo);
    }
    public static void updateData(BindDeviceInfo bindDeviceInfo){
        DbManager.getInstance().getDaoSession().getBindDeviceInfoDao().update(bindDeviceInfo);
    }

    public static List<BindDeviceInfo> queryAllData(){
        QueryBuilder<BindDeviceInfo> queryBuilder = DbManager.getInstance().getDaoSession().getBindDeviceInfoDao().queryBuilder();
        return queryBuilder.list();
    }
    public static BindDeviceInfo queryData(String address){
        QueryBuilder<BindDeviceInfo> queryBuilder = DbManager.getInstance().getDaoSession().getBindDeviceInfoDao().queryBuilder();
        return queryBuilder.where(BindDeviceInfoDao.Properties.MacAddress.eq(address)).unique();
    }

    public static void deleteAll(){
        DbManager.getInstance().getDaoSession().getBindDeviceInfoDao().deleteAll();;
    }
    public static void deleteDeviceInfo(String address){
        DbManager.getInstance().getDaoSession().getBindDeviceInfoDao().deleteByKey(address);;
    }

}
